package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class AddDrawAdapter extends StkProviderMultiAdapter<String> {

    public AddDrawAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new AddDrawProvider());
    }

    private int position;

    public void setPosition(int position) {
        this.position = position;
    }

    private class AddDrawProvider extends BaseItemProvider<String> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_add_draw;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, String bean) {
            baseViewHolder.setText(R.id.tvAddDrawItemName, bean);
            if (position == baseViewHolder.getBindingAdapterPosition()) {
                baseViewHolder.setBackgroundColor(R.id.llAddDrawItem, Color.parseColor("#D4D4D4"));
                baseViewHolder.setVisible(R.id.ivAddDrawItemSel, true);
                baseViewHolder.setTextColor(R.id.tvAddDrawItemName, Color.parseColor("#161515"));
            } else {
                baseViewHolder.setBackgroundColor(R.id.llAddDrawItem, 0);
                baseViewHolder.setVisible(R.id.ivAddDrawItemSel, false);
                baseViewHolder.setTextColor(R.id.tvAddDrawItemName, Color.parseColor("#A1A1A1"));
            }
        }
    }

}
